#include "gui/HumanPlayer.h"

void HumanPlayer::selectKnock() {
  if (game->getCurrPlayer() == order && game->getCurrPhase() == DrawPhase &&
      !game->isLastRound()) {
    game->knock(order);
    move.knock = true;
    move.cardDrawn.SetIdx(53);
    move.cardPicked.SetIdx(53);
    move.cardDiscarded.SetIdx(53);

    emit turnComplete(order, move);
  }
}

void HumanPlayer::selectDrawPile() {
  if (game->getCurrPlayer() == order && game->getCurrPhase() == DrawPhase) {
    CCard cardTaken = game->draw(order);
    move.cardDrawn.SetIdx(cardTaken.GetIndex());
    move.cardPicked.SetIdx(53);
    hand.Push(cardTaken);

    emit humanDrawOccurred(order);
  }
}

void HumanPlayer::selectDiscardPile() {
  if (game->getCurrPlayer() == order && game->getCurrPhase() == DrawPhase) {
    CCard cardTaken = game->pickUp(order);
    move.cardDrawn.SetIdx(53);
    move.cardPicked.SetIdx(cardTaken.GetIndex());
    hand.Push(cardTaken);

    emit humanPickOccurred(order);
  }
}

void HumanPlayer::selectHandCard(int selectedCard) {
  if (game->getCurrPlayer() == order && game->getCurrPhase() == DiscardPhase) {
    CCard cardDiscarded = hand.RemoveCard(selectedCard);
    move.cardDiscarded.SetIdx(cardDiscarded.GetIndex());
    game->doDiscard(cardDiscarded, order);

    emit humanDiscardOccurred(order);
    emit turnComplete(order, move);
  }
}

